package com.nuoniu.sibanyun.mapper.erp;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nuoniu.sibanyun.entity.erp.ErpAccountModule;
import com.nuoniu.sibanyun.entity.vo.ErpAccountModuleVo;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 账套模块设置 Mapper 接口
 * </p>
 *
 * @author baiqiang
 * @since 2020-09-22
 */
public interface ErpAccountModuleMapper extends BaseMapper<ErpAccountModule> {

    /**
     * 获取 租户 当前年份的账套模块设置
     * @return
     */
    @Select("SELECT\n" +
            "\tsm.id as orgModuleId,\n" +
            "\tsm.module_code,\n" +
            "\tsm.module_name,\n" +
            "\tu.real_name,\n" +
            "\team.*\n" +
            "FROM\n" +
            "\tsys_module sm\n" +
            "\t\n" +
            "\tLEFT JOIN fab_account_module eam ON sm.id = eam.module_id \n" +
            "\tAND eam.company_id = #{companyId} " +
            "\tAND eam.account_id = #{accountId} " +
            "\tLEFT JOIN sys_user u ON u.id = eam.enable_user_id\n" +
            "\tWHERE sm.is_system = 0")
    List<ErpAccountModuleVo> listCurrentErpAccountModuleVo(Integer companyId,Integer accountId);

}
